package com.base.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.base.po.voip.Sotreadv;
import com.base.service.SotreadvService;

/**
 * 商圈广告管理服务端
 * 
 * @author f
 *
 */
@Controller
@RequestMapping("/admin")
public class index_SotreAdv {

	@Autowired
	private SotreadvService sotreadvService; // 广告信息

	// 商圈广告首页
	@RequestMapping("/sotreAdvIndex")
	public ModelAndView sotreadvIndex(HttpServletRequest request) throws Exception {
		String userid = (String) request.getSession().getAttribute("adminUserId"); // 登录的用户ID
		if (userid == null) return new ModelAndView("jsp/loginCheck"); // 未登录
		return new ModelAndView("jsp/index_SotreAdv", "stadvList",
				sotreadvService.selectByAll(new Sotreadv(userid, (byte) 1)));
	}

	// 跳转添加商圈广告
	@RequestMapping("/addSotreAdv")
	public String addSotreadv() throws Exception {
		return "jsp/add_SotreAdv";
	}

	// 跳转修改商圈广告
	@RequestMapping("/updateSotreAdv")
	public ModelAndView updateSotreadv(String id) throws Exception {
		return new ModelAndView("jsp/update_SotreAdv", "sotreadv", sotreadvService.selectByPrimaryKey(id));
	}
}
